// onjava/Tuple2.java
// (c)2021 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
package onjava;

/**
 * 简单泛型 -> 元组库：将一组对象包装进了一个对象，该对象的接收方可以读取其中的元素，但
 * 不能往里放入新元素。这个概念也成为数据传输对象(Data Transfer Object)
 * 或者信使(Messenger)
 * 
 * 持有两个对象的元组
 *
 * @author Lucky Yang
 */
public class Tuple2<A, B> {
  public final A a1;
  public final B a2;

  public Tuple2(A a, B b) {
    a1 = a;
    a2 = b;
  }

  public String rep() {
    return a1 + ", " + a2;
  }

  @Override
  public String toString() {
    return "(" + rep() + ")";
  }
}
